package com.mujin.keji.collectionsystem.widget;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.mujin.keji.collectionsystem.R;

/**
 * 对话框工具类
 */
public class CollectionDialogUtils extends Dialog {

    public CollectionDialogUtils(Context context) {
        super(context, R.style.my_dialog_style);
    }

    public static CollectionDialogUtils getDialog(Context content, @LayoutRes int resource) {
        final CollectionDialogUtils dialog = new CollectionDialogUtils(content);
        View view = LayoutInflater.from(content).inflate(resource, new LinearLayout(content));
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        dialog.setContentView(view);
        return dialog;
    }

    public static CollectionDialogUtils getDialogNotTouchOutside(Context content, @LayoutRes int resource) {
        final CollectionDialogUtils dialog = new CollectionDialogUtils(content);
        View view = LayoutInflater.from(content).inflate(resource, new LinearLayout(content));
        dialog.setCancelable(false);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setContentView(view);
        return dialog;
    }
}


